class CreateAuthors < ActiveRecord::Migration
  def self.up
    create_table :authors do |t|
      t.column :name, :string, :default => "Anonyme"
      t.column :age, :integer, :default => 0
      t.timestamps
    end
    
    remove_column :books, :author
    add_column :books, :author_id, :integer
    
    add_index :books, :author_id
  end

  def self.down
    drop_table :authors
    add_column :books, :author, :string
    remove_column :books, :author_id
    
    remove_index :books, :author_id
  end
end
